#pragma once
#include "notewindow.h"

#define IDMI_NOTE_TOPMOST		WM_USER+1200
#define IDMI_NOTE_SAVE		WM_USER+1201
#define IDMI_NOTE_REVERT		WM_USER+1202
#define IDMI_NOTE_HIDE		WM_USER+1203
#define IDMI_NOTE_DELETE		WM_USER+1204
#define IDMI_NOTE_COLOR0		WM_USER+1205
#define IDMI_NOTE_COLOR1		WM_USER+1206
#define IDMI_NOTE_COLOR2		WM_USER+1207
#define IDMI_NOTE_COLOR3		WM_USER+1208
#define IDMI_NOTE_COLOR4		WM_USER+1209

class CNote
{
public:
	CNote(CppSQLite3DB* pdb, HINSTANCE hInst, HMENU hMenu, COLORREF color, 
		COLORREF* colors, BOOL autoLoad=FALSE);
	~CNote(void);

	CppSQLite3DB* pdb;

	__int64 id;
	tstring body,obody;
	tstring position;
	time_t created_at;
	time_t modified_at;
	BOOL visible;

	CNoteWindow *win;
	HINSTANCE hInst;
	HMENU hMenu;

	BOOL dirty;
	BOOL poschanged;
	BOOL topmost;
	COLORREF color;
	COLORREF* colors;

	void Update();
	void Reload();
	void Show();
	void Save();
	void Revert();
	void Delete();
	void Hide();
	void MakeTopmost(BOOL top);
	void GetPosition();
};

class CNoteMgr
{
public:
	CNoteMgr(CppSQLite3DB* pdb, HINSTANCE hInst);
	~CNoteMgr(void);

	CppSQLite3DB* pdb;
	HINSTANCE m_hInst;
	vector<CNote*> m_notesList;

	HMENU m_hMenu;

	CNote* Create();
	COLORREF color;
	COLORREF colors[5];

	void Load();
	void Save();

	void Delete();

	void Show(BOOL visible);

	void MakeTopmost(BOOL top);
};
